home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / ai.prl / mike2.exe / MIKE.INI < prev    next >
Encoding:
Text File  |  1990-09-16  |  2.4 KB  |  65 lines

  1. /* MIKE.INI
  2.    The file MIKE.PL always loads this file last, so this is the place
  3.    to add 'customizations'. A few sample customizations are included to
  4.    give you the idea.
  5.    If you want ['mike.pl'] to automatically load any Prolog files of
  6.    your own, we suggest you that you add
  7.        ?- reconsult('<yourfile>').
  8.    here within MIKE.INI
  9.  
  10. */
  11.  
  12. /* Customization 1: some extra syntactic sugar for enhancing rule syntax
  13.    with ordinary arithmetic operators.  If you want to add more of your
  14.    own in some other file, be sure to use the 'directive' form, e.g.
  15.          ?- allow_prolog_lhs(X < Y).
  16.          ?- allow_prolog_rhs(foo(X,Y)).
  17.    The first directive allows '<' to be used on the left hand side
  18.    (IF-PART) of a MIKE rule.
  19.    The second allows some user-defined predicate 'foo' to be used
  20.    on the right hand side (THEN-PART) of a MIKE rule.
  21.   (These directives are defined in the file ENGINE2.PL)
  22. */
  23.                       /* We want to use a new assignment operator ':=' */
  24. ?- op(740,xfx,':=').  /* So we declare it in Prolog */
  25.  
  26. Var := Term :-   /* Then we define its meaning in Prolog ... */
  27.    Var is Term.  /* Simply calls the built-in Prolog 'is' for assignment */
  28.  
  29. ?- allow_prolog_rhs(X := Y). /* Then we tell MIKE to allow it as a right-hand
  30.                                 side action */
  31.  
  32. /* The next four operators are already known to Prolog, so we just need
  33.    to tell MIKE that they should be allowed on the left hand side of rules */
  34.  
  35. ?- allow_prolog_lhs(X>Y).
  36. ?- allow_prolog_lhs(X<Y).
  37. ?- allow_prolog_lhs(X>=Y).
  38. ?- allow_prolog_lhs(X=<Y).
  39.  
  40. /*
  41. with the above declarations, you could now write a rule like this:
  42.  
  43.    rule foo forward
  44.     if
  45.       [annual_earnings, Person, AE] &
  46.       AE > 25000
  47.     then
  48.       MonthlySalary := AE/12 &
  49.       MonthlyTax := MonthlySalary*0.40 &
  50.       announce [Person, ' pays this higher rate montly tax: ', MonthlyTax].
  51.  
  52. additional comments about these operators are in the file READ.ME
  53. */
  54. ?- op(900,fx, ed).
  55.  
  56. ed FILENAME :-
  57.   edit(FILENAME, 180000).
  58.   /* second argument to 'edit' reserves that many bytes disk swapping space */
  59.  
  60. ?- reconsult('extras.pl').  /* TTY multiple-choice menus & 'forall' */
  61. /* Uncomment the next line if you want to experiment with a
  62.    'hypothetical worlds' mechanism, as illustrated in the files
  63.    RNWORLD.PL and STRWORLD.PL
  64. */
  65. /* ?- reconsult('worlds.pl'). */